import { ConfigService } from '@nestjs/config';

export interface AppConfig {
  name: string;
  port: number;
  globalPrefix: string;
  jwtSecret: string;
}

export interface RedisConfig {
  host: string;
  port: number;
  password?: string;
  db: number;
}

export interface LogConfig {
  enabled: boolean;
  level: string;
  maxFiles: number;
}

export const getAppConfig = (configService: ConfigService): AppConfig => ({
  name: configService.get('APP_NAME', 'kanliAdmin'),
  port: configService.get('ADMIN_APP_PORT', 7000),
  globalPrefix: configService.get('GLOBAL_PREFIX', '/api'),
  jwtSecret: configService.get('JWT_SECRET', '$%^ad123'),
});

// Redis 配置已移至 redis.config.ts

export const getLogConfig = (configService: ConfigService): LogConfig => ({
  enabled: configService.get('LOG_ON', false),
  level: configService.get('LOG_LEVEL', 'info'),
  maxFiles: configService.get('LOG_MAX_FILES', 10),
});
